package com.example.shop.logistics.dto;

import com.example.shop.logistics.enums.CourierType;
import com.example.shop.pojo.Courier;
import com.example.shop.pojo.Merchant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class DeliveryBill {
    /**
     * 要发货的订单
     */
    @NotNull
    private Long orderId;
    /**
     * 快递单号
     */
    @NotNull
    private Long courierNumber;
    /**
     * 快递类型
     */
    @NotNull
    private CourierType courierType;

    public Courier toCourier(Merchant sender){
        Courier courier = new Courier();
        courier.setSenderName(sender.getMerchantName())
                .setSenderPhone(sender.getMerchantPhone())
                .setSenderArea(sender.getMerchantArea())
                .setSenderDetailedAddress(sender.getMerchantDetailedAddress())
                .setSenderLatitude(sender.getMerchantLatitude())
                .setSenderLongitude(sender.getMerchantLongitude())
                .setCourierNumber(courierNumber)
                .setCourierType(courierType.getType());
        return courier;
    }
}
